local text = {}

local w = love.graphics.getWidth()
local cache = {}

local function cacheFont(size)
  if not cache[size] then
    cache[size] = love.graphics.newFont(12)
  end
  return cache[size]
end

function text.drawCenterText(text, y, size)
  local font = love.graphics.getFont()
  local cfont = cacheFont(size)
  if font ~= cfont then
    love.graphics.setFont(cfont)
  end
  
  local fw = cfont:getWidth(text)
  love.graphics.print(text, (w-fw)/2, y)
end

return text
